﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// 文件名：ClsBonusGetDAL.cs
/// 作  者：SAM
/// 时  间：2007-01-08
/// 说  明：ClsBonusGetDAL类信息相关处理
/// </summary>
public class ClsBonusGetDAL
{
    /// <summary>
    /// 数据库连接字符串
    /// </summary>
    private static string strSqlConnectionString = ConfigurationManager.AppSettings["SQLCONNECTIONSTRING"];

    /// <summary>
    /// 获取所有奖金发放信息
    /// </summary>
    /// <returns>返回资料清单信息数据集</returns>
    public DataSet GetBonus()
    {
        DataSet dst = new DataSet();
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlDataAdapter dat = new SqlDataAdapter("Pro_GetBonusGet", con);

        dat.SelectCommand.CommandType = CommandType.StoredProcedure;

        try
        {
            dat.Fill(dst);
        }
        catch
        {
            dst = null;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

        return dst;
    }

    /// <summary>
    /// 作废资料清单信息
    /// </summary>
    /// <param>资料清单编号</param>
    /// <param name="Is_Visible">作废状态1为临时作废，－1为彻底作废</param>
    /// <returns>返回作废是否成功</returns>
    public Boolean DeleteBonus(string b_id, int Is_Visible)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_DeleteBonusGet", con);

        com.CommandType = CommandType.StoredProcedure;
        com.Parameters.Add("@b_id", SqlDbType.NVarChar, 20);
        com.Parameters["@b_id"].Value = b_id;
        com.Parameters.Add("@is_visible", SqlDbType.Int, 1);
        com.Parameters["@is_visible"].Value = Is_Visible;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 确认资料清单信息
    /// </summary>
    /// <param>资料清单编号</param>
    /// <param name="AuditStat">确认状态</param>
    /// <param name="Auditor">确认人</param>
    /// <returns>返回确认是否成功</returns>
    public Boolean AuditStatBonus(string ID, int AuditStat, string Auditor)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_AuditStatSetBonus", con);

        com.CommandType = CommandType.StoredProcedure;
        com.Parameters.Add("@id", SqlDbType.NVarChar, 20);
        com.Parameters["@id"].Value = ID;
        com.Parameters.Add("@is_audit", SqlDbType.Int);
        com.Parameters["@is_audit"].Value = AuditStat;
        com.Parameters.Add("@auditor", SqlDbType.NVarChar, 60);
        com.Parameters["@auditor"].Value = Auditor;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 增加奖金发放信息
    /// </summary>
    /// <param>......</param>
    /// <returns>返回修改是否成功</returns>
    public Boolean AddBonus(string b_id,DateTime b_date,string dp_id,string wk_id,decimal cprice,decimal price, string sabstract, string remark,string oper)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_AddBounsGet", con);

        com.CommandType = CommandType.StoredProcedure;
        com.Parameters.Add("@b_id", SqlDbType.NVarChar, 20);
        com.Parameters["@b_id"].Value = b_id;
        com.Parameters.Add("@b_date", SqlDbType.DateTime, 8);
        com.Parameters["@b_date"].Value = b_date; 

        com.Parameters.Add("@dp_id", SqlDbType.NVarChar, 30);
        com.Parameters["@dp_id"].Value = dp_id;
        com.Parameters.Add("@wk_id", SqlDbType.NVarChar, 30);
        com.Parameters["@wk_id"].Value = wk_id;        
        com.Parameters.Add("@cprice", SqlDbType.Decimal, 38);
        com.Parameters["@cprice"].Value = cprice;
        com.Parameters.Add("@price", SqlDbType.Decimal, 38);
        com.Parameters["@price"].Value = price;
        com.Parameters.Add("@abstract", SqlDbType.NVarChar, 255);
        com.Parameters["@abstract"].Value = sabstract;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = remark;
        com.Parameters.Add("@oper", SqlDbType.NVarChar, 30);
        com.Parameters["@oper"].Value = oper;


        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

    /// <summary>
    /// 修改奖金发放信息
    /// </summary>
    /// <param>......</param>
    /// <returns>返回修改是否成功</returns>
    public Boolean UpDateBonus(string b_id, DateTime b_date, string dp_id, string wk_id, decimal cprice, decimal price, string sabstract, string Remark)
    {
        SqlConnection con = new SqlConnection(strSqlConnectionString);
        SqlCommand com = new SqlCommand("Pro_UpDateBonusGet", con);
        com.CommandType = CommandType.StoredProcedure;

        com.Parameters.Add("@b_id", SqlDbType.NVarChar, 30);
        com.Parameters["@b_id"].Value = b_id;
        com.Parameters.Add("@b_date", SqlDbType.DateTime);
        com.Parameters["@b_date"].Value = b_date;
        com.Parameters.Add("@dp_id", SqlDbType.NVarChar, 30);
        com.Parameters["@dp_id"].Value = dp_id;
        com.Parameters.Add("@wk_id", SqlDbType.NVarChar, 30);
        com.Parameters["@wk_id"].Value = wk_id;
        com.Parameters.Add("@cprice", SqlDbType.Decimal, 28);
        com.Parameters["@cprice"].Value = cprice;
        com.Parameters.Add("@price", SqlDbType.Decimal, 28);
        com.Parameters["@price"].Value = price;

        com.Parameters.Add("@abstract", SqlDbType.NVarChar, 255);
        com.Parameters["@abstract"].Value = sabstract;
        com.Parameters.Add("@remark", SqlDbType.NVarChar, 255);
        com.Parameters["@remark"].Value = Remark;

        try
        {
            con.Open();
            com.ExecuteNonQuery();

            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }
    }

}
